<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>BMI测试</h1>
<form >
    <input type="text" name="height" placeholder="身高(米)"><br>
    <input type="text" name="weight" placeholder="体重(kg)"><br>
    <input type="button" value="测试" @click="test()"><br>
    <h3>{{info}}</h3>
</form>
<!--引入axios和vue-->
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.14/vue.js"></script>
<script>
    let v = new Vue({
        el:"form",
        data:{
            info:""
        },
        methods:{
            test(){
                //获取表单数据
                let formData = new FormData(document.querySelector("form"));
                //发起post异步请求
                axios.post("/test",formData).then(function (response) {
                    //测试结果显示在页面上
                    v.info =response.data;
                })
            }
        }
    })
</script>
</body>
</html>